package com.example.day6;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public static int num=0;
    Button button1;
    TextView text;
    public MainActivity (){
        num++;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("####main111111111","onCreate");
        setContentView(R.layout.activity_main);
        Intent intent = getIntent();
        String aa=intent.getStringExtra("name");
        button1=findViewById(R.id.button);
        text=findViewById(R.id.textView);
        text.setText(num+"");

        if(aa!=null){
            button1.setText(aa);
        }
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Intent intent = new Intent();
//                intent.setAction("mytest");
//                intent.addCategory("com.sun.category");
//                intent.putExtra("name","wangzhen");
//                startActivity(intent);
//                finish();
//                Intent intent = new Intent(MainActivity.this,Main3Activity.class);
//                startActivity(intent);
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.baidu.com"));
                startActivity(intent);
            }
        });

    }
    @Override
    protected void onStart() {
        super.onStart();
        Log.e("####main1","onStart");
    }
    @Override
    protected void onResume() {
        super.onResume();
        Log.e("####main1","onResume");
    }
    @Override
    protected void onPause() {
        super.onPause();
        Log.e("####main1","onPause");
    }
    @Override
    protected void onStop() {
        super.onStop();
        Log.e("####main1","onStop");
    }
    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e("####main1","onRestart");
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("####main1","onDestroy");
    }
}
